import random


def generate_lucky_numbers():
    return sorted(random.sample(range(1, 34), 8))


def get_user_numbers():
    user_numbers = []
    print("请输入8个1到33之间的整数作为您的投注号码，每个号码之间用空格分隔:")
    while len(user_numbers) < 8:
        try:
            input_numbers = input().split()
            for num in input_numbers:
                num = int(num)
                if 1 <= num <= 33 and num not in user_numbers:
                    user_numbers.append(num)
                else:
                    print(f"无效的数字: {num}。请确保输入1到33之间的整数且不重复。")
        except ValueError:
            print("输入无效，请确保输入的是整数。")
    return sorted(user_numbers)


def check_prize(lucky_numbers, user_numbers):
    correct_count = len(set(lucky_numbers) & set(user_numbers))
    if correct_count == 8:
        return "一等奖"
    elif correct_count == 7:
        return "二等奖"
    elif correct_count == 6:
        return "三等奖"
    elif correct_count == 5:
        return "四等奖"
    else:
        return "未中奖"


def simulate_lottery(lucky_numbers, num_simulations=10000):
    prize_counts = {
        "一等奖": 0,
        "二等奖": 0,
        "三等奖": 0,
        "四等奖": 0,
        "未中奖": 0
    }

    for _ in range(num_simulations):
        simulated_numbers = sorted(random.sample(range(1, 34), 8))
        prize = check_prize(lucky_numbers, simulated_numbers)
        prize_counts[prize] += 1

    return prize_counts


def main():
    lucky_numbers = generate_lucky_numbers()
    print(f"系统生成的中奖号码: {lucky_numbers}")

    user_numbers = get_user_numbers()
    print(f"您输入的号码: {user_numbers}")

    prize = check_prize(lucky_numbers, user_numbers)
    print(f"恭喜您获得: {prize}")

    # 模拟10000次
    prize_counts = simulate_lottery(lucky_numbers)
    total_simulations = sum(prize_counts.values())
    print("\n模拟10000次的结果：")
    for prize, count in prize_counts.items():
        probability = (count / total_simulations) * 100
        print(f"{prize}: {count}次, 概率: {probability:.2f}%")

if __name__ == "__main__":
    main()